package com.lxl.settings.service.impl;

import com.lxl.commons.mapper.IMapper;
import com.lxl.commons.mapper.impl.UserMapperImpl;
import com.lxl.settings.dao.UserDao;
import com.lxl.settings.dao.UserDaoImpl;
import com.lxl.settings.entity.User;
import com.lxl.settings.service.UserService;

import java.sql.SQLException;
import java.util.List;

/**
 * @author 北上寻海
 */
public class UserServiceImpl implements UserService {

    /**
     * 要注入上一层的对象才能调用
     */
    UserDao userDao = new UserDaoImpl();
    IMapper userMapper = new UserMapperImpl();
    @Override
    public List<User> queryUser(String username, String password) throws SQLException {
        return  userMapper.mapper(userDao.selectUserByCondition(username,password));
    }

    @Override
    public int addUser(User user) throws SQLException {
        return userDao.insertUserByCondition(user);
    }

    @Override
    public List<User> selectUserById(String id) throws SQLException {
        return userMapper.mapper(userDao.selectUserById(id));
    }
}
